package com.pan.admin.module.api.dao;

import com.pan.admin.module.api.entity.ApiKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * keysDao接口
 *
 * @author ts
 * @date 2023-10-26
 */
@Mapper
public interface ApiKeyDao {

    /**
     * api渠道
     */
    List<Map<String, Object>> listApiKey(@Param("keyword") String keyword);

    String findLoanChannelNameByApiChannelId(@Param("loanChannelId") Long loanChannelId);

    String findLoanChannelNameByChannelId(@Param("loanChannelId") Long loanChannelId);

    String findApiNameByApiCleanId(@Param("apiClientId") String apiClientId);

    /**
     * 根据ID获取列表keys
     *
     * @param id keys主键
     * @return keys
     */
    ApiKey getById(Long id);

    /**
     * 查询keys列表
     *
     * @param apiKeys keys
     * @return keys集合
     */
    List<ApiKey> list(ApiKey apiKeys);

    /**
     * 新增keys
     *
     * @param apiKeys keys
     * @return 结果
     */
    int insertApiKeys(ApiKey apiKeys);

    /**
     * 修改keys
     *
     * @param apiKeys keys
     * @return 结果
     */
    int updateApiKeys(ApiKey apiKeys);


    /**
     * 查重
     *
     * @param apiName
     * @return
     */
    ApiKey checkApiName(String apiName);

    /**
     *
     *  功能描述: 根据api_client_id 获取
     *  @author hrj
     *
     *  @param apiKey
     *  @return com.pan.admin.module.api.entity.ApiKey
     */
    ApiKey getByApiClientId(String id);

    /**
     *  更新余额
     */
    int updateBalance(ApiKey apiKey);
}
